package com.huo.base.controller;


import org.springframework.http.CacheControl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.request.ServletWebRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * http://localhost:10061/hp/cacheControl
 * 发送请求
 */

@Controller
@RequestMapping("/big")
public class BigFileController {


    @RequestMapping(value = "/cacheControl",method = RequestMethod.GET)
    public String cache(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap){
        System.out.println(new Date(  ));
        String headervalue = CacheControl.maxAge( 10, TimeUnit.SECONDS ).getHeaderValue();
        response.addHeader( "Cache-Control",headervalue);
        System.out.println("=============");
        return "cache";

    }


    private String  s(){
        System.out.println("33");
        return "";
    }




}
